Matrix
A 2D matrix of floating-point values.
- Matrix.add(m1, m2)
-
Adds two matrices of the same size.
- Matrix.addConstant(matrix, value)
- Arguments:
matrix (
Matrix)value (
float)
Adds the value to each matrix element.
- Matrix.concatenate(m1, m2, concatHorizontally)
-
Returns the concatenation of the two matrices.
- Matrix.create(rows, cols)
- Arguments:
rows (
int)cols (
int)
- Return type:
Creates a new matrix.
- Matrix.createFromVector(vector, rows, cols)
- Arguments:
vector (
float)rows (
int)cols (
int)
- Return type:
Creates a new matrix from a vector in row-major order.
- Matrix.createIdentity(size)
- Argument:
size (
int)
- Return type:
Creates a new identity matrix.
- Matrix.determinant(matrix)
- Argument:
matrix (
Matrix)
- Return type:
float
Returns the determinant of the matrix.
- Matrix.getColumn(matrix, colIndex)
-
Returns one or multiple columns of the matrix. The columns are returned as a MxK matrix, where M is the number of rows of the original matrix and K is the number of column indices in colIndex.
- Matrix.getRow(matrix, rowIndex)
-
Returns one or multiple rows of the matrix. The rows are returned as a KxN matrix, where N is the number of columns of the original matrix and K is the number of row indices in rowIndex.
- Matrix.getSize(matrix)
- Argument:
matrix (
Matrix)
- Return type:
int
Returns the number of rows and columns of the matrix.
- Matrix.getValue(matrix, rowIndex, colIndex)
- Arguments:
matrix (
Matrix)rowIndex (
int)colIndex (
int)
- Return type:
float
Returns the value of the indexed matrix element. The first element has index (0,0).
- Matrix.max(matrix)
- Argument:
matrix (
Matrix)
- Return type:
float
Returns the maximum value of the matrix.
- Matrix.min(matrix)
- Argument:
matrix (
Matrix)
- Return type:
float
Returns the minimum value of the matrix.
- Matrix.multiply(m1, m2)
-
Multiplies two matrices. The first matrix must have the same number of columns as the second matrix has rows.
- Matrix.multiplyConstant(matrix, value)
- Arguments:
matrix (
Matrix)value (
float)
Multiplies each matrix element with the value.
- Matrix.norm(matrix)
- Argument:
matrix (
Matrix)
- Return type:
float
Returns the Frobenius norm of the matrix, the square root of the sum of the squares of its elements.
- Matrix.setAll(matrix, value)
- Arguments:
matrix (
Matrix)value (
float)
Sets the whole matrix to the same value.
- Matrix.setColumn(matrix, colIndex, newColumn)
-
Sets one or multiple columns of the matrix.
- Matrix.setRow(matrix, rowIndex, newRow)
-
Sets one or multiple rows of the matrix.
- Matrix.setValue(matrix, rowIndex, colIndex, value)
- Arguments:
matrix (
Matrix)rowIndex (
int)colIndex (
int)value (
float)
Sets the value in the indexed matrix element. The first element has index (0,0).
- Matrix.solve(a, b)
-
Computes the least squares solution to the equation system Ax = b. A is an NxM matrix. b is an Nx1 matrix. x is an Mx1 matrix and the solution to the equation system.
- Matrix.subtract(m1, m2)
-
Subtracts two matrices of the same size.
- Matrix.sumColumns(matrix)
-
Computes the sum of each column. The column sums are returned as a 1xN row matrix.
- Matrix.sumRows(matrix)
-
Computes the sum of each row. The row sums are returned as a Mx1 column matrix.
- Matrix.svd(matrix)
-
Computes the singular value decomposition of an NxM matrix. U is the left singular vectors and U the right singular vectors corresponding to singular values S. In both U and V vectors are in the columns of each matrix such that matrix = U*diag(S)*V^T.
- Matrix.tile(matrix, n, m)
-
Returns an n-by-m tiling of the matrix.
- Matrix.toImage(matrix)
-
Converts a matrix to a float64 image.
- Matrix.toPoints(matrix, storedInColumns)
-
Converts a matrix to a vector of 2D or 3D points.
- Matrix.toString(matrix)
- Argument:
matrix (
Matrix)
- Return type:
string
Get a string representation of the matrix.